package lab01;

import java.util.Scanner;

public class Test12 {
    public static void main(String[] args) {
        System.out.println("请输入一个1-9999的数：");
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();

        if (num < 1 || num > 9999) {
            System.out.println("输入错误，请输入1-9999范围内的数！！！！");
        } else if (num / 1000 != 0) {

            //判断输入的数是否为四位数

            System.out.println(num + "是一个四位数");

            //分别求出个位，十位，百位和千位上的数字

            int one = num % 10;
            int ten = num / 10 % 10;
            int hun = num / 100 % 10;
            int thou = num / 1000 % 10;
            if (one == thou && ten == hun) {
                System.out.println(num + "是回文数");
            } else
                System.out.println(num + "不是回文数");
        } else if (num / 100 != 0) {

            //判断输入的数是否为三位数

            System.out.println(num + "是一个三位数");

            //分别求出个位，十位，百位上的数字

            int one = num % 10;
            int ten = num / 10 % 10;
            int hun = num / 100 % 10;
            if (one == hun) {
                System.out.println(num + "是回文数");
            } else
                System.out.println(num + "不是回文数");
        } else if (num / 10 != 0) {

            //判断输入的数是否为二位数

            System.out.println(num + "是一个二位数");

            //分别求出个位，十位上的数字

            int one = num % 10;
            int ten = num / 10 % 10;
            if (one == ten) {
                System.out.println(num + "是回文数");
            } else
                System.out.println(num + "不是回文数");
        } else
            System.out.println(num + "是一个一位数");
    }
}
